{extend name="base_mobile" /}
{block name="body"}
<header class="hui-header">
    <div id="hui-back"></div>
    <h1>编辑客户</h1>
</header>
<div class="hui-wrap">
    <form action="{:request()->url()}" class="hui-form" method="post">
        <div class="hui-form-items">
            <div class="hui-form-items-title">客户名称</div>
            <input type="text" name="cname" value="{$data.cname|default=''}" autocomplete="off" class="hui-input hui-input-clear">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">客户电话</div>
            <input type="text" name="mobile" value="{$data.mobile|default=''}" autocomplete="off" class="hui-input">
        </div>
        {foreach name="config" item="config"}
        <div class="hui-form-items">
            <div class="hui-form-items-title">{$config.title}</div>
            {if $config.type eq 'input'}
            <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" autocomplete="off" class="hui-input hui-input-clear">
            {/if}
            {if $config.type eq 'textarea'}
            <div class="hui-form-textarea">
                <textarea name="{$config.name}" placeholder="请输入{$config.title}">{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}</textarea>
            </div>
            {/if}
            {if $config.type eq 'select'}
            {if $config.is_sys eq '1'}
            <div class="hui-form-select">
                <select name="{$config.name}">
                    {foreach name=":parse_attr($config.options)" key="i" item="j"}
                    <option value="{$i}" {if condition="$data[$config.name] eq $i"}selected="selected"{/if}>{$j}</option>
                    {/foreach}
                </select>
            </div>
            {else}
            <div class="hui-form-select">
                <select name="{$config.name}">
                    {foreach name=":parse_attr($config.options)" key="i" item="j"}
                    <option value="{$i}" {if condition="isset($data.jdata[$config.name]) eq $i"}selected="selected"{/if}>{$j}</option>
                    {/foreach}
                </select>
            </div>
            {/if}
            {/if}
            {if $config.type eq 'radio'}
            {foreach name=":parse_attr($config.options)" key="i" item="j"}
            <div class="hui-form-radios" style="line-height:38px;">
                <input type="radio" name="{$config.name}" value="{$i}" title="{$j}" {if condition="isset($data.jdata[$config.name]) eq $i"}checked="checked"{/if}>
            </div>
            {/foreach}
            {/if}
            {if $config.type eq 'image'}
            <input type="text" name="{$config.name}" value="{if isset($data.jdata[$config.name])}{$data.jdata[$config.name]}{else}{$config.value|default=''}{/if}" autocomplete="off" placeholder="请上传{$config.title}" class="hui-input" style="width:200px;">
            <button type="button" class="hui-btn hui-btn-primary hui-btn-position ajax-images"><i class="fa fa-file-image-o"></i> 选择图片</button>
            {/if}
            {if $config.is_sys eq '1'}
            <div class="hui-form-mid hui-word-aux"><a class="hui-button hui-button-small hui-fl" href="{:url('user/config/index')}">设置参数值</a></div>
            {/if}
        </div>
        {/foreach}
        <div class="hui-form-items">
            <div class="hui-form-items-title">选择地区</div>
            <button type="button" class="hui-button hui-button-large" id="btn2">{$data.province|default=''} / {$data.city|default=''} / {$data.area|default=''}</button>
            <input type="hidden" name="province" value="{$data.province|default=''}" class="hui-input hui-input-clear" id="province">
            <input type="hidden" name="city" value="{$data.city|default=''}" class="hui-input hui-input-clear" id="city">
            <input type="hidden" name="area" value="{$data.area|default=''}" class="hui-input hui-input-clear" id="area">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">详细地址</div>
            <input type="text" name="address" value="{$data.address|default=''}" autocomplete="off" class="hui-input">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">备注</div>
            <div class="hui-form-textarea">
                <textarea name="remark" class="layui-textarea">{$data.remark|default=''}</textarea>
            </div>
        </div>
        
        <div style="padding:15px 8px;">
            <button class="hui-button hui-button-large hui-primary" lay-filter="*" lay-submit="">保存</button>
        </div>
    </form>
</div>
<br><br><br>
{/block}
{block name="js"}
<script type="text/javascript" src="/static/hui/js/hui-picker.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/hui/js/cities.js" charset="utf-8"></script>
<script type="text/javascript">
/* 地区选择， 关联型数据 */
var picker2 = new huiPicker('#btn2', function(){
    var sheng   = picker2.getText(0);
    var shi     = picker2.getText(1);
    var qu      = picker2.getText(2);
    document.getElementById("province").value= sheng;
    document.getElementById("city").value= shi;
    document.getElementById("area").value= qu;
    hui('#btn2').html(sheng + ' / ' + shi + ' / ' + qu);
});
picker2.level = 3;
//cities 数据来源于 cities.js
picker2.bindRelevanceData(cities);
</script>
{/block}
